﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Csla.Data;
using Csla;

namespace Kiosk.Library
{
    public partial class Slide
    {
        /// <summary>
        /// Deletes all the slides for a specific presentation
        /// </summary>
        /// <param name="presID">The presentation's slides we want to remove</param>
        public static void DeleteAllByPresentationID(Guid presID)
        {
            //TODO: This could be done as a batch delete
            SlideReadOnlyList slides =  SlideReadOnlyList.GetSlidesByPresentationID(presID);
            foreach (SlideInfo s in slides)
            {
                Slide.DeleteSlide(s.SlideID);
            }
        }

        public static void ReorderSlide(Guid SlideID, int NewOrder)
        {
            using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
            {
                ctx.DataContext.ReorderSlide(SlideID,  NewOrder);
            }
        }
    }
}
